import { defHttp } from "@/utils/http";

export interface userModel {
	id: string | number;
	avatar: string;
	nickname: string;
}

// * 登录
export interface userLoginReqDTO {
	username: string;
	password: string;
	// captchaVerification: string;
}
export interface userLoginResDTO {
	userId: string | number;
	accessToken: string;
	refreshToken: string;
	expiresTime: number;
}

export interface userInfoResDTO {
	roles: string[];
	permissions: string[];
	menus: Menu.MenuOptions[];
	// 用户id
	user: userModel;
}

export interface ResAuthButtons {
	[propName: string]: any;
}

// 用户登录接口
export const userLoginApi = (params: userLoginReqDTO) => {
	return defHttp.post<userLoginResDTO>({ url: `/system/auth/login`, params });
};

// 用户信息及权限
export const getUserInfoApi = () => {
	return defHttp.get<userInfoResDTO>({ url: `/system/auth/get-permission-info` });
};
